let str = `gif|jpg|bmp|jpeg|png|ico|mp4|pdf|xls|xlsx|doc|docx|zip|rar|txt`

let img = [
  "gif",
  "jpg",
  "bmp",
  "jpeg",
  "png",
  "ico"
]

let notImg = [
  "mp4",
  "pdf",
  "xls",
  "xlsx",
  "doc",
  "docx",
  "zip",
  "rar",
  "txt"
]

let document = [
  'doc',
  'docx',
  'xls',
  'xlsx',
  'ppt',
  'pptx',
  'pdf'
]

let getExtension = (fileName = '') => {
  if (!fileName.includes('.')) {
    return ''
  }
  let arr = fileName.split('.')
  let extension = arr[arr.length - 1]
  return extension
}

let getFileName = (fileName = '') => {
  if (!fileName.includes('/')) {
    return ''
  }
  let arr = fileName.split('/')
  let name = arr[arr.length - 1]
  return name
}

let isImage = (extension = '') => {
  if (img.includes(extension)) {
    return true
  }
  return false
}

let isDocument = (extension = '') => {
  if (document.includes(extension)) {
    return true
  }
  return false
}

export {
  getExtension,
  isImage,
  getFileName,
  isDocument
}